<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Internationalization (i18n) and Localization (l10n) - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/performance.localization.html">Inglês (English)</a></li>
    <li><a href="../pt-br/performance.localization.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="performance.database.html">Zend_Db Performance</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="performance.html">Zend Framework Performance Guide</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="performance.view.html">View Rendering</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="performance.localization" class="section"><div class="info"><h1 class="title">Internationalization (i18n) and Localization (l10n)</h1></div>
    

    <p class="para">
        Internationalizing and localizing a site are fantastic ways to expand
        your audience and ensure that all visitors can get to the information
        they need. However, it often comes with a performance penalty. Below
        are some strategies you can employ to reduce the overhead of i18n and
        l10n.
    </p>

    <div class="section" id="performance.localization.translationadapter"><div class="info"><h1 class="title">Which translation adapter should I use?</h1></div>
        

        <p class="para">
            Not all translation adapters are made equal. Some have more
            features than others, and some perform better than others.
            Additionally, you may have business requirements that force you to
            use a particular adapter. However, if you have a choice, which
            adapters are fastest?
        </p>

        <div class="section" id="performance.localization.translationadapter.fastest"><div class="info"><h1 class="title">Use non-XML translation adapters for greatest speed</h1></div>
            

            <p class="para">
                Zend Framework ships with a variety of translation adapters.
                Fully half of them utilize an <acronym class="acronym">XML</acronym> format, incurring memory and
                performance overhead. Fortunately, there are several adapters
                that utilize other formats that can be parsed much more
                quickly. In order of speed, from fastest to slowest, they are:
            </p>

            <ul class="itemizedlist">
                <li class="listitem">
                    <p class="para">
                        <em class="emphasis">Array</em>: this is the fastest, as it is, by
                        definition, parsed into a native <acronym class="acronym">PHP</acronym> format immediately
                        on inclusion.
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        <em class="emphasis"><acronym class="acronym">CSV</acronym></em>: uses
                         <span class="methodname">fgetcsv()</span> to parse a <acronym class="acronym">CSV</acronym> file
                        and transform it into a native <acronym class="acronym">PHP</acronym> format.
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        <em class="emphasis"><acronym class="acronym">INI</acronym></em>: uses
                         <span class="methodname">parse_ini_file()</span> to parse an <acronym class="acronym">INI</acronym>
                        file and transform it into a native <acronym class="acronym">PHP</acronym> format. This and
                        the <acronym class="acronym">CSV</acronym> adapter are roughly equivalent performance-wise.
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        <em class="emphasis">Gettext</em>: The gettext adapter from Zend Framework
                        does <em class="emphasis">not</em> use the gettext
                        extension as it is not thread safe and does not allow
                        specifying more than one locale per server. As a result, it
                        is slower than using the gettext extension directly, but,
                        because the gettext format is binary, it&#039;s faster to parse
                        than <acronym class="acronym">XML</acronym>.
                    </p>
                </li>
            </ul>

            <p class="para">
                If high performance is one of your concerns, we suggest
                utilizing one of the above adapters.
            </p>
        </div>
    </div>

    <div class="section" id="performance.localization.cache"><div class="info"><h1 class="title">How can I make translation and localization even faster?</h1></div>
        

        <p class="para">
            Maybe, for business reasons, you&#039;re limited to an <acronym class="acronym">XML</acronym>-based
            translation adapter. Or perhaps you&#039;d like to speed things up even
            more. Or perhaps you want to make l10n operations faster. How can
            you do this?
        </p>

        <div class="section" id="performance.localization.cache.usage"><div class="info"><h1 class="title">Use translation and localization caches</h1></div>
            

            <p class="para">
                Both <span class="classname">Zend_Translate</span> and <span class="classname">Zend_Locale</span>
                implement caching functionality that can greatly affect
                performance. In the case of each, the major bottleneck is
                typically reading the files, not the actual lookups; using a
                cache eliminates the need to read the translation and/or
                localization files.
            </p>

            <p class="para">
                You can read about caching of translation and localization
                strings in the following locations:
            </p>

            <ul class="itemizedlist">
                <li class="listitem">
                    <p class="para">
                        <a href="zend.translate.adapter.html#zend.translate.adapter.caching" class="link"><span class="classname">Zend_Translate</span>
                            adapter caching</a>
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        <a href="zend.locale.introduction.html#zend.locale.cache" class="link"><span class="classname">Zend_Locale</span>
                            caching</a>
                    </p>
                </li>
            </ul>
        </div>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="performance.database.html">Zend_Db Performance</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="performance.html">Zend Framework Performance Guide</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="performance.view.html">View Rendering</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="performance.html">Zend Framework Performance Guide</a></li>
  <li><a href="performance.introduction.html">Introduction</a></li>
  <li><a href="performance.classloading.html">Class Loading</a></li>
  <li><a href="performance.database.html">Zend_Db Performance</a></li>
  <li class="active"><a href="performance.localization.html">Internationalization (i18n) and Localization (l10n)</a></li>
  <li><a href="performance.view.html">View Rendering</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>